import ctypes

TW_OPENGL           = 1
TW_DIRECT3D9        = 2
TW_DIRECT3D10       = 3

TW_TYPE_UNDEF   = 0,
##ifdef __cplusplus
#TW_TYPE_BOOLCPP = 1,
##endif // __cplusplus
TW_TYPE_BOOL8   = 2,
TW_TYPE_BOOL16 = 3
TW_TYPE_BOOL32 = 4
TW_TYPE_CHAR = 5
TW_TYPE_INT8 = 6
TW_TYPE_UINT8 = 7
TW_TYPE_INT16 = 8
TW_TYPE_UINT16 = 9
TW_TYPE_INT32 = 10
TW_TYPE_UINT32 = 11
TW_TYPE_FLOAT = 12
TW_TYPE_DOUBLE = 13
TW_TYPE_COLOR32 = 14
TW_TYPE_COLOR3F = 15
TW_TYPE_COLOR4F = 16
TW_TYPE_CDSTRING = 17

TW_MOUSE_RELEASED = 0
TW_MOUSE_PRESSED = 1

TW_KMOD_NONE        = 0x0000  
TW_KMOD_SHIFT       = 0x0003
TW_KMOD_CTRL        = 0x00c0
TW_KMOD_ALT         = 0x0100
TW_KMOD_META        = 0x0c00

TW_MOUSE_LEFT       = 1
TW_MOUSE_MIDDLE     = 2
TW_MOUSE_RIGHT      = 3

BUTTONFUNC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
SETFUNC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
GETFUNC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
ERRORFUNC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p);

def _load_dll():
    from ctypes.util import find_library
    return ctypes.CDLL(find_library('AntTweakBar'))
atb_dll = _load_dll()

atb_dll.TwGetLastError.restype = ctypes.c_char_p
atb_dll.TwGetBarName.restype = ctypes.c_char_p



